import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

public class O28 {
    public static void main(String[] args) {
        AtomicInteger i = new AtomicInteger();
    }
    public boolean isSymmetric(TreeNode root) {
        if (root==null)
            return true;
        return dfs(root.left,root.right);
    }
    boolean dfs(TreeNode left,TreeNode right){
        if (left==null&&right==null)
            return true;
        if (left==null||right==null)
            return false;
        if (left.val!=right.val)
            return false;
        return dfs(left.left,right.right)&&dfs(right.left,left.right);
    }
}
